package com.sinothk.gpserver.modules.biz.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sinothk.gpserver.modules.biz.entity.GroupEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 群(俱乐部) Mapper 接口
 * </p>
 *
 * @author Liang Y.t.
 * @since 2021-08-28
 */
@Mapper
@Repository
public interface GroupMapper extends BaseMapper<GroupEntity> {

    @Select("SELECT g.*, gm.group_role,gm.member_coins FROM biz_group g LEFT JOIN biz_group_member gm ON g.id = gm.group_id WHERE gm.member_account = '${userAccount}' AND gm.deleted = 0 ORDER BY create_time DESC")
    IPage<GroupEntity> pageForMember(Page<GroupEntity> page, String userAccount);

}
